<!DOCTYPE html>
<html>
<head>
    <th:block th:include="include :: headermain('互助保障系统')"/>
    <script type="text/javascript">if (!!window.ActiveXObject || "ActiveXObject" in window) location.href = '/Unit/Browser';</script>
</head>
<body>

<div class="page">

    <th:block th:include="include :: top"/>


    <div class="center">
        <div class="page-content page-wrap">
            <th:block th:include="include :: left"/>
            <div class="page-wrap-container">

                <div class="">
                    <div class="">
                        <div class="page-advice">

                            <div class="page-tab">
                                <a class="on" href="/hzhelp/advice/hzHelpAdvice/form">提交问题</a>
                                <a href="/hzhelp/advice/hzHelpAdvice/adviceList">我的问题</a>
                            </div>

                            <form class="page-form">
                                <input type="hidden" name="unitid" value="${hzUnit.id}"/>
                                <div class="page-form-item">
                                    <div class="page-form-label">意见类型：</div>
                                    <div class="page-form-input">
                                        <select name="types">
                                            <c:forEach items="${fns:getDictList('advice_type')}" var="item">
                                                <option value="${item.value}">${item.label}</option>
                                            </c:forEach>
                                            <option value="">其他</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="page-form-item">
                                    <div class="page-form-label">意见内容：</div>
                                    <div class="page-form-input">
                                        <textarea name="content" id="content"></textarea>
                                    </div>
                                </div>
                                <div class="page-form-item">
                                    <div class="page-form-label">联系人：</div>
                                    <div class="page-form-input">
                                        <input type="text" style="width:100px" name="contact"
                                               value="${hzUnit.contact}"/>
                                    </div>
                                </div>
                                <div class="page-form-item">
                                    <div class="page-form-label">联系手机：</div>
                                    <div class="page-form-input">
                                        <input type="text" style="width:150px" name="mobile" value="${hzUnit.mobile}"/>
                                    </div>
                                </div>
                                <div class="page-form-item">
                                    <div class="page-form-label">联系邮箱：</div>
                                    <div class="page-form-input">
                                        <input type="text" style="width:150px" name="email" value="${hzUnit.email}"/>
                                    </div>
                                </div>
                                <div class="page-form-item">
                                    <div class="page-form-label">验证码：</div>
                                    <div class="page-form-input">
                                        <input type="text" name="code" style="width:50px"
                                               class="page-form-input-captcha"/>
                                        <input class="page-form-input-captcha-check" type="hidden" name="Code_Check"
                                               value="">
                                        <!--      <img class="page-form-input-captcha-img " id = "imgObj" src=""> -->
                                        <img id="imgObj" height="36" width="85" onclick="changeImg()" alt="验证码"
                                             src="/code/getcode">
                                    </div>
                                </div>


                                <div class="page-form-item">
                                    <div class="page-form-label"></div>
                                    <div class="page-form-input">
                                        <a class="layui-btn">立即提交</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>


    <th:block th:include="include :: footer"/>

</div>


<script src="/footerjs.js"></script>

<script type="text/javascript">

    $(".layui-btn").click(function () {
        var content = $("#content").val();
        if (content) {
            $.soon.ajax({
                url: "/hzhelp/advice/hzHelpAdvice/adviceSubmit",
                data: $(".page-form").serialize(),
                async: false,
                success: function (data) {
                    if (data.success) {
                        layer.alert("登记成功，工作人员将及时处理并告知您处理结果，请保证您的电话畅通", function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(data.msg);
                    }
                }
            });
        } else {
            layer.msg("请填写意见内容");
        }

    });


    function changeImg() {
        var imgSrc = $("#imgObj");
        var src = imgSrc.attr("src");
        imgSrc.attr("src", chgUrl(src));
    }

    // 时间戳
    // 为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳
    function chgUrl(url) {
        var timestamp = (new Date()).valueOf();
        url = url.substring(0, 22);
        if ((url.indexOf("&") >= 0)) {
            url = url + "×tamp=" + timestamp;
        } else {
            url = url + "?timestamp=" + timestamp;
        }
        return url;
    }


</script>


</body>
</html>
